#ifndef CHATCLIENT_H
#define CHATCLIENT_H

#include <QCoreApplication>
#include <QSslSocket>
#include <qsslconfiguration.h>
#include <QDataStream>
#include <QDateTime>
#include <QDebug>
#include <QSslKey>
#include <QFile>
#include <QTimer>
#include <QThread>


class chatClient: public QObject
{
    Q_OBJECT

public:
    chatClient(QObject *parent = nullptr);

    chatClient(QString userName,QString caCertificateFilePath,QString clientCertificateFilePath,QString clientKeyPath,QObject *parent = nullptr);

    void setConfig();

    void setConfig(QString caCertificateFilePath,QString clientCertificateFilePath,QString clientKeyPath);

    void sendMessage(const QString &message);


signals:

    void receiveMessage(QString message);

public slots:

    void readMessage();

    void onEncrypted();

    void onSslErrors(const QList<QSslError> &errors);

    void onDisconnected();

    void onError(QAbstractSocket::SocketError socketError);

private:
    QString userName;

    QSslSocket *socket;
    //ca证书路径
    QString caCertificateFilePath;
    //客户端证书路径
    QString clientCertificateFilePath;
    //私钥路径
    QString clientKeyPath;

};
#endif // CHATCLIENT_H
